package com.example.dwr.ticketcenter;

import java.util.Date;
import org.directwebremoting.Security;

public class Call
{
  private Date callStarted;
  private String notes;
  private boolean supervisorAlert;
  private String name;
  private String address;
  private String phoneNumber;
  private int id;
  private String handlerId;

  public Call()
  {
    this.callStarted = new Date();

    this.notes = "";

    this.supervisorAlert = false;
  }

  public Date getCallStarted()
  {
    return this.callStarted;
  }

  public void setCallStarted(Date callStarted)
  {
    this.callStarted = callStarted;
  }

  public String getWaitTime()
  {
    long timePlain = new Date().getTime() - this.callStarted.getTime();
    int time = 10000 * Math.round((float)(timePlain / 10000L));
    return "" + time;
  }

  public String getNotes()
  {
    return this.notes;
  }

  public void setNotes(String notes)
  {
    this.notes = notes;
  }

  public boolean isSupervisorAlert()
  {
    return this.supervisorAlert;
  }

  public void setSupervisorAlert(boolean supervisorAlert)
  {
    this.supervisorAlert = supervisorAlert;
  }

  public String getAddress()
  {
    return this.address;
  }

  public void setAddress(String address)
  {
    this.address = Security.escapeHtml(address);
  }

  public int getId()
  {
    return this.id;
  }

  public void setId(int id)
  {
    this.id = id;
  }

  public String getName()
  {
    return this.name;
  }

  public void setName(String name)
  {
    this.name = Security.escapeHtml(name);
  }

  public String getPhoneNumber()
  {
    return this.phoneNumber;
  }

  public void setPhoneNumber(String phoneNumber)
  {
    this.phoneNumber = phoneNumber;
  }

  protected String getHandlerId()
  {
    return this.handlerId;
  }

  protected void setHandlerId(String handlerId)
  {
    this.handlerId = handlerId;
  }

  public boolean isHandled()
  {
    return (this.handlerId != null);
  }

  public boolean equals(Object obj)
  {
    if (obj == null)
    {
      return false;
    }

    if (obj == this)
    {
      return true;
    }

    if (!(super.getClass().equals(obj.getClass())))
    {
      return false;
    }

    Call that = (Call)obj;

    return (this.id == that.id);
  }

  public int hashCode()
  {
    return (5924 + this.id);
  }

  public String toString()
  {
    return "Person[id=" + this.id + ",name=" + this.name + "]";
  }
}